package com.zmj.quartz.task;

import org.springframework.stereotype.Component;

import java.io.IOException;

    @Component("backUpDb")
    public class BackUpDb {

        public void backup(String msg) {

            try {
                System.out.println(msg);
                Runtime runtime = Runtime.getRuntime();
                String fileName = System.currentTimeMillis() + ".sql";
                runtime.exec("mysqldump -uroot -pzmj12345 mydb -r D:\\备份数据" + fileName);
                System.out.println("备份成功！");
            } catch (IOException e) {
                e.printStackTrace();
            }

        }


}
